﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xinkui.Entity.AutoGenerator;
using DataFrameworkAccess;
using Xinkui.Common;

namespace Xinkui.DataAccess.AutoGenerator {
    public partial class ProductInfoDataAccess {
        public List<ProductInfo_Entity> SearchProducts(int pageIndex, int pageSize, string keyword, out int total) {
            total = 0;
            try {
                int tempRecord = 0;
                if (pageIndex <= 0) pageIndex = 1;
                DataCommand cmd = DataCommandManager.GetDataCommand("Search.Products");
                cmd.SetParameterValue("@where", WhereHelper.Product.CreateSearchWhere(keyword));
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@PageIndex", pageIndex);
                cmd.SetParameterValue("@RecordCount", tempRecord);
                List<ProductInfo_Entity> pageList = cmd.ExecuteEntityList<ProductInfo_Entity>();
                object cmdGetParameterValue = cmd.GetParameterValue("@RecordCount");
                if (!(cmdGetParameterValue is DBNull)) {
                    total = Convert.ToInt32(cmdGetParameterValue);
                }
                return pageList;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<ProductInfo_Entity>(0);
        }
    }
}
